home *** CD-ROM | disk | FTP | other *** search
/ Acorn RISC PD-CD 1 / Acorn RISC PD-CD 1.iso / languages / perl / examples / nl < prev    next >
Encoding:
Text File  |  1990-07-20  |  328 b   |  16 lines

  1. # Perl script to convert CR/NL, CR, NL/CR into NL
  2.  
  3. die "Usage: NL in out\n" unless $#ARGV == 1;
  4.  
  5. $* = 1;        # Strings may contain NL
  6. undef $/;    # Slurp the whole file
  7.  
  8. open(IN,$ARGV[0]) || die "Cannot open $ARGV[0]: $!\n";
  9. open(OUT,">$ARGV[1]") || die "Cannot open $ARGV[1]: $!\n";
  10.  
  11. $_ = <IN>;
  12.  
  13. s/\r\n|\r|\n\r/\n/g;
  14.  
  15. print OUT $_;
  16.